<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$return['status']=$this->member_status;
$return['sex']=$this->sex;
$return['xueli_type']=$this->xueli_type;
$return['fromtype']=$this->fromtype;
$return['jietype']=$this->jietype;
$return['isshiming']=$this->isshiming;
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if(!empty($_RQ['usename'])){
		$params['usename like']='%'.trim($_RQ['usename']).'%';
		$return['params']['usename']=$_RQ['usename'];
	}
	if(!empty($_RQ['mobile'])){
		$params['mobile like']='%'.trim($_RQ['mobile']).'%';
		$return['params']['mobile']=$_RQ['mobile'];
	}
	if(!empty($_RQ['status'])){
		$params['status']=trim($_RQ['status']);
		$return['params']['status']=intval($_RQ['status']);
	}
    $orderby='id desc';
	$total='';
	$return['list']=pdo_getslice('jy_51job_member',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$item){
		$item['member']=$this->model('member')->member_show($item['id']);
		$item['pcd']=json_decode($item['pcd'],true);
		if(!$item['pcd']['province'] && $item['pcd']['city']){
				if(mb_substr($item['pcd']['city'],-1)!='市'){
					$item['pcd']['city']=$item['pcd']['city'].'市';
				}
				if(mb_substr($item['pcd']['district'],-1)!='区'){
					$item['pcd']['district']=$item['pcd']['district'].'区';
				}
				$parent_code=pdo_getcolumn('core_area',array('type'=>2,'title'=>$item['pcd']['city']),'parent_code');
				$item['pcd']['province']=pdo_getcolumn('core_area',array('type'=>1,'code'=>$parent_code),'title');
				if($item['pcd']['province']){
					pdo_update('jy_51job_member',array('pcd'=>ijson_encode($item['pcd'])),array('id'=>$item['id'],'uniacid'=>$_SESSION['uniacid']));
				}
		}
	}
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'人才池'),
			array('op'=>'edit','title'=>'添加人才'),
		),
		'list'=>array('data'=>'list','edit'=>true,'list'=>array(
			array('name'=>'member','title'=>'人才信息','type'=>'member'),
			array('name'=>'member.mobile','title'=>'手机号','type'=>'string'),
			array('name'=>'codesn','title'=>'证件号码','type'=>'string'),
			array('name'=>'isshiming','title'=>'实名认证','type'=>'radio','options'=>'isshiming'),
			array('name'=>'banktitle','title'=>'银行卡','type'=>'string'),
			array('name'=>'jietype','title'=>'接单设置','type'=>'radio','options'=>'jietype'),
			array('name'=>'codeimg1','title'=>'身份证头像面','type'=>'image'),
			array('name'=>'codeimg2','title'=>'身份证国徽面','type'=>'image'),
			array('name'=>'pcd','title'=>'所属区域','type'=>'pcd'),
			array('name'=>'codetime','title'=>'实名时间','type'=>'time'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
			array('name'=>'uptime','title'=>'最近时间','type'=>'time'),
			array('name'=>'createtime','title'=>'注册时间','type'=>'time'),
			array('name'=>'fromtype','title'=>'邀请通道','type'=>'radio','options'=>'fromtype'),
			
		),'action'=>array(
			array('type'=>'modal','op'=>'look','title'=>'详情'),
			array('type'=>'modal','op'=>'change','title'=>'更换手机号'),
		)),
		'search'=>array(
			array('name'=>'usename','width'=>10,'title'=>'人才姓名','type'=>'string'),
			array('name'=>'mobile','width'=>10,'title'=>'手机号','type'=>'string'),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='edit'){
	$id=intval($_RQ['id']);
	if($id){
		$item=pdo_get('jy_51job_member',array('id'=>$id));
		if($item['birth']){
			$item['age']=date('Y')-$item['birth'];
		}
	}else{
		$item=array();
	}
    $return['item']=$item;
	$htmls=array(
		'type'=>'edit',
		'post'=>'post',
		'edit_tab'=>true,
		'edits'=>array(
			array(
				'title'=>'个人信息',
				'list'=>array(
					array('name'=>'usename','title'=>'姓名','type'=>'string'),
					array('type'=>'radio','title'=>'性别','name'=>'sex','options'=>'sex'),
					array('type'=>'string_two','title'=>'年龄','title1'=>'出生年分','title2'=>'年龄','name1'=>'birth','name2'=>'age','read2'=>true),
					array('name'=>'mobile','title'=>'手机号','type'=>'string'),
					array('type'=>'string','title'=>'微信号','name'=>'wechat'),
					array('type'=>'string','title'=>'邮箱','name'=>'email'),
					array('type'=>'string','title'=>'QQ','name'=>'qq'),
					array('name'=>'pcd','title'=>'所属区域','type'=>'pcd'),
					array('type'=>'string','title'=>'详细地址','name'=>'address'),
					array('type'=>'string','title'=>'专业','name'=>'zhuanye'),
					array('type'=>'string','title'=>'毕业学校','name'=>'school'),
					array('type'=>'radio','title'=>'学历','name'=>'xueli','options'=>'xueli_type'),
					array('type'=>'string','title'=>'应聘岗位','name'=>'gangwei'),
					array('type'=>'string','title'=>'工作经验','name'=>'workdesc'),
					array('type'=>'image','title'=>'学信网/证书','name'=>'xueliimg','help'=>''),
					array('name'=>'jietype','title'=>'接单设置','type'=>'radio','options'=>'jietype'),
					array('name'=>'fromtype','title'=>'邀请通道','type'=>'radio','options'=>'fromtype'),
					array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
				)
			),
		   array(
				'title'=>'身份信息',
				'list'=>array(
					array('name'=>'isshiming','title'=>'实名认证','type'=>'radio','options'=>'isshiming'),
					array('name'=>'codetime','title'=>'实名时间','type'=>'time'),
					array('type'=>'string','title'=>'身份证号码','name'=>'codesn','help'=>''),
					array('type'=>'string','title'=>'详细地址','name'=>'address','help'=>''),
					array('type'=>'string','title'=>'银行卡号','name'=>'bankno','help'=>''),
					array('type'=>'string','title'=>'银行支行','name'=>'banktitle','help'=>''),
					array('type'=>'image','title'=>'银行卡正面照片','name'=>'bankimg','help'=>''),
					array('type'=>'image','title'=>'身份证正面','name'=>'codeimg1','help'=>''),
					array('type'=>'image','title'=>'身份证背面','name'=>'codeimg2','help'=>''),
					array('name'=>'codeimg1','title'=>'身份证头像面','type'=>'image'),
					array('name'=>'codeimg2','title'=>'身份证国徽面','type'=>'image'),
					array('name'=>'weituoimg','title'=>'社税委托授权','type'=>'image'),
					array('name'=>'codevideo','title'=>'认证视频','type'=>'video'),
				)
			),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='look'){
	$id=intval($_RQ['id']);
	if($id){
		$item=pdo_get('jy_51job_member',array('id'=>$id));
	}else{
		$item=array();
	}
    $return['item']=$item;
	$htmls=array(
		'type'=>'look',
		'look_tab'=>true,
		'looks'=>array(
			array(
				'title'=>'个人信息',
				'list'=>array(
					array('name'=>'usename','title'=>'姓名','type'=>'string'),
					array('type'=>'radio','title'=>'性别','name'=>'sex','options'=>'sex'),
					array('type'=>'string','title'=>'年龄','name'=>'age'),
					array('name'=>'mobile','title'=>'手机号','type'=>'string'),
					array('type'=>'string','title'=>'微信号','name'=>'wechat'),
					array('type'=>'string','title'=>'邮箱','name'=>'email'),
					array('type'=>'string','title'=>'QQ','name'=>'qq'),
					array('name'=>'pcd','title'=>'所属区域','type'=>'pcd'),
					array('type'=>'string','title'=>'详细地址','name'=>'address'),
					array('type'=>'string','title'=>'专业','name'=>'zhuanye'),
					array('type'=>'string','title'=>'毕业学校','name'=>'school'),
					array('type'=>'radio','title'=>'学历','name'=>'xueli','options'=>'xueli_type'),
					array('type'=>'string','title'=>'应聘岗位','name'=>'gangwei'),
					array('type'=>'string','title'=>'工作经验','name'=>'workdesc'),
					array('type'=>'image','title'=>'学信网/证书','name'=>'xueliimg','help'=>''),
					array('name'=>'jietype','title'=>'接单设置','type'=>'radio','options'=>'jietype'),
					array('name'=>'fromtype','title'=>'邀请通道','type'=>'radio','options'=>'fromtype'),
					array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'status'),
					array('name'=>'uptime','title'=>'最近时间','type'=>'time'),
					array('name'=>'createtime','title'=>'注册时间','type'=>'time'),
				)
			),
		   array(
				'title'=>'身份信息',
				'list'=>array(
					array('name'=>'isshiming','title'=>'实名认证','type'=>'radio','options'=>'isshiming'),
					array('name'=>'codetime','title'=>'实名时间','type'=>'time'),
					array('type'=>'string','title'=>'身份证号码','name'=>'codesn','help'=>''),
					array('type'=>'string','title'=>'详细地址','name'=>'address','help'=>''),
					array('type'=>'string','title'=>'银行卡号','name'=>'bankno','help'=>''),
					array('type'=>'string','title'=>'银行支行','name'=>'banktitle','help'=>''),
					array('type'=>'image','title'=>'银行卡正面照片','name'=>'bankimg','help'=>''),
					array('type'=>'image','title'=>'身份证正面','name'=>'codeimg1','help'=>''),
					array('type'=>'image','title'=>'身份证背面','name'=>'codeimg2','help'=>''),
					array('name'=>'codeimg1','title'=>'身份证头像面','type'=>'image'),
					array('name'=>'codeimg2','title'=>'身份证国徽面','type'=>'image'),
					array('name'=>'weituoimg','title'=>'社税委托授权','type'=>'image'),
					array('name'=>'codevideo','title'=>'认证视频','type'=>'video'),
				)
			),
		)
	);
	$return['sex']=$this->sex;
	$return['xueli_type']=$this->xueli_type;
	$return['fromtype']=$this->fromtype;
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='post'){
	$postdata=get_postdata();
	if(!$postdata['usename']){
		exi('姓名不能为空！','error');
	}
	$data=array(
		'usename'=>trim($postdata['usename']),
		'mobile'=>trim($postdata['mobile']),
		'avatar'=>trim($postdata['avatar']),
		'sex'=>intval($postdata['sex']),
		'isshiming'=>trim($postdata['isshiming']),
		'jietype'=>trim($postdata['jietype']),
		'codesn'=>trim($postdata['codesn']),
		'codeimg1'=>trim($postdata['codeimg1']),
		'codeimg2'=>trim($postdata['codeimg2']),
		'codevideo'=>trim($postdata['codevideo']),
		'weituoimg'=>trim($postdata['weituoimg']),
		'pcd'=>ijson_encode($postdata['pcd']),
		'address'=>trim($postdata['address']),
		'fromtype'=>trim($postdata['fromtype']),
		'xueli'=>trim($postdata['xueli']),
		'birth'=>trim($postdata['birth']),
		'wechat'=>trim($postdata['wechat']),
		'email'=>trim($postdata['email']),
		'qq'=>trim($postdata['qq']),
		'zhuanye'=>trim($postdata['zhuanye']),
		'school'=>trim($postdata['school']),
		'gangwei'=>trim($postdata['gangwei']),
		'workdesc'=>trim($postdata['workdesc']),
		'xueliimg'=>trim($postdata['xueliimg']),
		'banktitle'=>trim($postdata['banktitle']),
		'bankno'=>trim($postdata['bankno']),
		'bankimg'=>trim($postdata['bankimg']),
		'banktitle'=>trim($postdata['banktitle']),
		'status'=>intval($postdata['status']),		
	);
	$id=intval($postdata['id']);
	if($id){
		pdo_update('jy_51job_member',$data,array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	}else{
		$data['uniacid']=$_SESSION['uniacid'];
		$data['uptime']=time();
		$data['createtime']=time();
		pdo_insert('jy_51job_member',$data);
	}
	exi('操作成功！','','list');
}
if($_RQ['op']=='change'){
	if($_RQ['postdata']){
		$post=get_postdata();
		$id=intval($post['id']);
		$this->update('member',array('mobile'=>$post['mobile']),array('id'=>$id));
		exi('修改手机成功！','','list');
	}
	$item=$this->get('member',array('id'=>intval($_RQ['id'])),array('id','mobile'));
	if(!$item){
		exi('指定客户不存在！','error');
	}
	$return['item']=$item;
	$return['htmls']=array(
		'type'=>'edit',
		'desc'=>'修改手机',
		'edit'=>array(
			array('type'=>'string','name'=>'mobile','title'=>'设置手机','help'=>'手机异常时操作'),
		),
	);
	exi($return);
}
if($_RQ['op']=='del'){
	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('jy_51job_member',array('id'=>$id));	
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				pdo_delete('jy_51job_member',array('id'=>$id));
			}
		}
	}
	exi('删除成功！');
}
?>